#ifndef DWM_USER_CONNECTION_MANAGER_H 
#define DWM_USER_CONNECTION_MANAGER_H 1

#include "userconnection.h"

#include "logging.h"

#include <vector>
#include <map>

using boost::asio::ip::tcp;

// *****************************************
class UserConnectionManager : LoggingService
{

public:
  explicit UserConnectionManager(boost::asio::io_service& io);


  // shuts down all active connections
  void closeAll();


  /*
  UserConnection * registerUserSocketFrom(const boost::shared_ptr<tcp::socket>& socket);

  UserConnection * registerUserSocketTo(const boost::shared_ptr<tcp::socket>& socket);
*/

  UserConnection * registerUserSocket(const boost::shared_ptr<tcp::socket>& socket, bool direction);




private:
  UserConnection * getUserConnectionByAddress(const std::string& address);

  void printConnections();

  std::map<std::string, UserConnection*> m_address_to_connection;

  std::vector<UserConnection*> m_conn_unauthorized;

  boost::asio::io_service * m_io_service;


};


#endif 
